package com.lonty.intelligence.controller;

import com.lonty.intelligence.api.Result;
import com.lonty.intelligence.api.ResultCode;
import com.lonty.intelligence.service.OwnerService;
import com.lonty.intelligence.vo.OwnerVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Author 陈璇
 * @Date 2020/4/20 10:52
 * @Version 1.0
 */
@RestController
@RequestMapping("app/owner")
@Validated
@Api(tags = "业主接口", produces = "application/json")
public class OwnerController {

    @Resource
    private OwnerService ownerService;

    @ApiOperation(value = "保存业主", httpMethod = "POST")
    @PostMapping("saveOwner")
    public Result saveOwner(@ModelAttribute OwnerVo ownerVo){
        return ownerService.saveOwner(ownerVo);
    }

    @ApiOperation(value = "根据楼栋ID获取业主详细信息", httpMethod = "GET")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "buildingId", value = "楼栋ID",dataType = "string", paramType = "query", required = true)
    })
    @GetMapping("getOwnerInfo")
    public Result getOwnerInfo(String buildingId){
        return Result.builder()
                .data(ownerService.getOwnerInfo(buildingId))
                .build();
    }

}
